<?php

/**
* Simple Machines Forum (SMF) 
*
* @package testsuite
* @author Simple Machines
* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0
*/

function template_main()
{
	global $context, $scripturl, $settings, $txt;
	// Start our template...
	echo ' 
	<div class="cat_bar">
		<h3 class="catbg">', $txt['sm_testsuite_main'], '</h3>
	</div>
	<div class="information">', $txt['sm_testsuite_desc'], '</div>';
	// Shout a button calling people to create projects :P
	echo '
	<div class="buttons">
		<ul>
			<li>
				<a class="active" href="', $context['test_suite']['url'], ';createproject"><span>', $txt['create_project'], '</span></a>
			</li>
		</ul>
	</div>';
	// Show info of the projects created so far
	echo '
	<div class="suite_frame">';
	if (empty($context['test_suite']['projects']))
		echo '
		<div class="error">' . $txt['ts_no_loaded_projects'] . '</div>';

	echo '
		<ul>';
	foreach ($context['test_suite']['projects'] as $key => $value)
	{
		echo '
			<li class="header">
				<strong>', $txt['project_name'], '</strong>', ': ', $value['link'], '
				<div class="floatright">
					<a class="active" href="', $context['test_suite']['url'], ';editproject=', $value['id'], '">
						<img src="' . $settings['images_url'] . '/buttons/sm_edit.png" alt="', $txt['edit_project'], '" title="', $txt['edit_project'], '" />
					</a>
					<a class="active" href="', $context['test_suite']['url'], ';removeproject='. $value['id'] . '">
						<img src="' . $settings['images_url'] . '/buttons/sm_delete.png" alt="', $txt['remove_project'], '" title="', $txt['edit_project'], '" />
					</a>
				</div>
			</li>';

		echo '
			<li class="text_style">
				<strong>', $txt['project_description'], '</strong>
			</li>
			<li class="suite_frame_right">', $value['description'], '</li><br />';

		if(!empty($value['modified_by']))
			echo '
			<li class="modified">
				', $txt['ts_last_edit_by'], ' ', $value['modified_by'], ' ', $txt['at'], ' ', $value['modified_time'], '
			</li>';

		echo '
		<li class="bottom_margin"></li>';
	}
		echo '
		</ul><hr class="clear" />
	</div>';
}

function template_sm_testsuite_project_view()
{
	global $txt, $scripturl, $suite, $context, $settings;
	// Start our template...
	echo '
	<div class="cat_bar">   
		<h3 class="catbg">', $txt['project_action'], '</h3>
	</div>
	<div class="information">', $context['test_suite']['project']['description'], '</div>';
	
	// Shout a button calling people to create suites :P
	echo '
		<div class="buttons">
			<ul>
				<li><a class="active" href="', $context['test_suite']['url'], ';createsuite;proj=' . $context['test_suite']['current_project'] .'"><span>', $txt['create_suite'], '</span></a></li>
			</ul>
		</div>';

		// Show info of the suites created so far
		if (isset($context['test_suite']['project']['suites']))
		{
			echo '
		<div class="suite_frame">';
			if (empty($context['test_suite']['project']['suites']))
			echo '
		<div class="error">' . $txt['ts_no_loaded_suites'] . '</div>';
			foreach ($context['test_suite']['project']['suites'] as $key => $value)
			{
				echo '
		<ul>
		<li class="header"><strong>', $txt['suite_name'], '</strong>', ': ', $value['link'], '
			<div class="floatright">
				<a class ="active" href="', $context['test_suite']['url'], ';editsuite='. $value['id'] . '">
					<img src="' . $settings['images_url'] . '/buttons/sm_edit.png" alt="', $txt['edit_suite'], '" title="', $txt['edit_suite'], '" />
				</a>
				<a class ="active" href="', $context['test_suite']['url'], ';removesuite='. $value['id'] . '">
						<img src="' . $settings['images_url'] . '/buttons/sm_delete.png" alt="', $txt['remove_suite'], '" title="', $txt['edit_project'], '" />
				</a>
			</div>
		</li>';
				echo '
		<li class="text_style">
			<strong>', $txt['suite_description'], '</strong></li>
			<li class="suite_frame_right">', $value['description'], '</li>
		</li>';

				if (empty($value['count']))
					echo '
		<li class="text_style">
			<strong>', $txt['total_run_count'], '</strong>: ', $value['count'], '
		</li>';
				else
					echo '
		<li class="text_style">
			<strong>', $txt['total_run_count'], '</strong>: ', $value['count_link'], '
		</li>';

				if (empty($value['pass_count']))
					echo '
					<li class="text_style">
							<strong>', $txt['pass_count'], '</strong>: ', $value['pass_count'], '
					</li>';
				else
					echo '
					<li class="text_style">
							<strong>', $txt['pass_count'], '</strong>: ', $value['pass_count_link'], '
					</li>';

				if (empty($value['fail_count']))
						echo '
					<li class="text_style">
							<strong>', $txt['fail_count'], '</strong>: ', $value['fail_count'], '
					</li>';
				else
						echo '
					<li class="text_style">
							<strong>', $txt['fail_count'], '</strong>: ', $value['fail_count_link'], '
					</li>';

					if (!empty($value['modified_by']))
						echo '
								<li class="modified">', 'Last edited by', ' ', $value['modified_by'], ' ', $txt['at'], ' ', $value['modified_time'], '</li>';
				echo '
								<li class="bottom_margin"><hr class="clear" /></li>
						</ul>';
				}
				
		echo '
				</div>';
		}
}

function template_sm_testsuite_case_view()
{
		global $txt, $scripturl, $context, $settings;
		// Start our template...
		echo '
				<div class="cat_bar">   
						<h3 class="catbg">', $txt['suite_action'], ': ', $context['test_suite']['suite']['link'], '</h3>
				</div>
				<div class="information">', $context['test_suite']['suite']['description'], '</div>';

		// Shout a button calling people to create test cases :P
		echo '
				<div class="buttons">
						<ul>
								<li><a class ="active" href="', $context['test_suite']['url'], ';createcase;s=' . $context['test_suite']['current_suite'] .'"><span>', $txt['create_case'], '</span></a></li>
						</ul>
				</div>';
				
		// Show info of the test cases created so far
		if (isset($context['test_suite']['suite']['cases']))
		{
			echo '
						<div class="suite_frame">';
			
			if (empty($context['test_suite']['suite']['cases']))
				echo '
					<div class="error">' . $txt['ts_no_loaded_cases'] . '</div>';

			echo '
						<ul>';
						foreach ($context['test_suite']['suite']['cases'] as $key => $value)
						{
				echo '
						<li class="header"><strong>', $txt['case_name'], '</strong>', ': ', $value['link'], '
							<div class="floatright">
								<a class="active" href="', $context['test_suite']['url'], ';editcase='. $value['id'] . '">
									<img src="' . $settings['images_url'] . '/buttons/sm_edit.png" alt="', $txt['edit'], ' ', $txt['case'], '" title="', $txt['edit'], ' ', $txt['case'], '" />
								</a>
								<a class="active" href="', $context['test_suite']['url'], ';removecase='. $value['id'] . '">
									<img src="' . $settings['images_url'] . '/buttons/sm_delete.png" alt="', $txt['remove_case'], '" title="', $txt['edit_project'], '" />
								</a>
							</div>
						</li>';
				echo '
						<li class="text_style"><strong>', $txt['case_description'], '</strong></li>
						<li class="suite_frame_right">', $value['description'], '</li>';
				echo '
						<li class="text_style"><strong>', $txt['total_run_count'], '</strong>', ': ', $value['count'], '</li>';
				echo '
						<li class="text_style"><strong>', $txt['pass_count'], '</strong>', ': ', $value['pass_count'], '</li>';
				echo '
						<li class="text_style"><strong>', $txt['fail_count'], '</strong>', ': ', $value['fail_count'], '</li>';
				if(!empty($value['modified_by']))
					echo '
						<li class="modified">', 'Last edited by', ' ', $value['modified_by'], ' ', $txt['at'], ' ', $value['modified_time'], '</li>';
				echo '
				<li class="bottom_margin"><hr class="clear" /></li>';
						}
						
				echo '
						</ul>
				</div>';
		}
}

function template_sm_testsuite_separate_case_view()
{
	global $txt, $scripturl, $context, $run, $settings;
	
	// Start our template...
	echo '
	<div class="suite_frame">';

		// Time to get boxes in places :P, div power. Show all infomation regarding to this specific test case
		echo '
		<div class="cat_bar">
			<h3 class="catbg">', $txt['case_action'], '</h3>
		</div>';
		
	// If a run was just deleted.
	if (!isset($context['test_suite']['alerts']['deleted']))
		echo '
		<div id="delete-notify">', $txt['ts_run_deleted'], '</div>';
		
	echo '
		<ul>';
	echo '
		<li class="details">
				<strong>', $txt['project_id'], '</strong>: ', $context['test_suite']['case']['id_project'], '
		</li>';
			
	echo '
		<li class="details">
				<strong>', $txt['suite_id'], '</strong>: ', $context['test_suite']['case']['id_suite'], '
		</li>';
			
	echo '
		<li class="details">
				<strong>', $txt['case_id'], '</strong>: ', $context['test_suite']['case']['id'], '
		</li>';
	if(!empty($context['test_suite']['case']['id_assigned']))
	{
		echo '
		<li class="details">
			<strong>', $txt['assigned_to'], ': ' , '</strong>', $context['test_suite']['case']['id_assigned'], '
		</li>';
	}
		
	echo '
		<li class="bottom_margin"><hr class="clear" /></li>';
	
	echo '
		<li class="details">
			<strong>', $txt['case_name'], '</strong>
		</li><li><hr class="clear" /></li>';
	echo '
		<li class="suite_frame_right">', $context['test_suite']['case']['name'], '</li>
		<li class="bottom_margin"><hr class="clear" /></li>';
	
	echo '
		<li class="details">
			<strong>', $txt['description'], '</strong>
		</li><li><hr class="clear" /></li>';
			
	echo '
			<li class="suite_frame_right">',  $context['test_suite']['case']['description'], '</li>
			<li class="bottom_margin"><hr class="clear" /></li>';
	
	echo '
		<li class="details">
					<strong>', $txt['steps'], '</strong>
		</li><li><hr class="clear" /></li>';
		
	echo '
			<li class="suite_frame_right">',  $context['test_suite']['case']['steps'], '</li>
			<li class="bottom_margin"><hr class="clear" /></li>';
		
	echo '
			<li class="details">
					<strong>', $txt['expected_result'], '</strong>
			</li><li><hr class="clear" /></li>';
		
		echo '
				<li class="suite_frame_right">',  $context['test_suite']['case']['expected_result'], '</li>
				<li><hr class="clear" /></li>';

		echo '
				</ul></div>';
		
		// Shout a button calling people to submit there run results :P
		echo '
				<div class="buttons">
					<ul>
						<li>
							<a class="active" href="', $context['test_suite']['url'], ';editcase=' . $context['test_suite']['current_case'] .'">
								<span>', $txt['edit_case'], '</span>
							</a>
						</li>
						<li class="more">
							<a class="active" href="', $context['test_suite']['url'], ';createrun;c=' . $context['test_suite']['case']['id'] .'">
								<span>', $txt['submit_run_result'], '</span>
							</a>
						</li>
					</ul>
				</div><br /><br />';
		
		// Show info of the run feedback regarding to this test case
		if (!empty($context['test_suite']['case']['runs']))
		{
			echo '
		<div class="suite_frame">';
			echo '
			<div class="cat_bar">
				<h3 class="catbg">', $txt['run_list'], '</h3>
			</div>';
			echo '
				<ul>';
			foreach ($context['test_suite']['case']['runs'] as $key => $value)
			{
				echo '
				<li class="header">
					<strong>', $txt['ran_by'], '</strong>', ' - ', $value['member']['link'], '
					<div class="floatright"><span>', $value['time'], '</span>
						<a class="active" href="', $context['test_suite']['url'], ';editrun='. $value['id'] . '">
							<img src="' . $settings['images_url'] . '/buttons/sm_edit.png" alt="', $txt['ts_edit_run'], '" title="', $txt['ts_edit_run'], '" />
						</a>
						<a class="active" href="', $context['test_suite']['url'], ';removerun='. $value['id'] . '">
							<img src="' . $settings['images_url'] . '/buttons/sm_delete.png" alt="', $txt['ts_delete_run'], '" title="', $txt['ts_delete_run'], '" />
						</a>
					</div>
				</li>';
				echo '
				<li><a id="run', $value['id'], '"></a></li>';	
				echo '
				<li class="', $value['result_achieved'] == 'fail' ? 'text_style red' : 'text_style','">
					<strong>', $txt['run_id'], '</strong>', ' - ', '
					<a style="', $value['result_achieved'] == 'fail' ? 'color:#ff0000;' : '','" href="', $value['href'], '">', $value['id'], '</a>
				</li>';
				echo '
				<li class="', $value['result_achieved'] == 'fail' ? 'text_style red' : 'text_style','">
						<strong>', $txt['run_result'], '</strong>', ' - ', $value['result_achieved'], '
				</li>';
		
				echo '
				<li class="text_style">
						<strong>', $txt['feedback'], ':</strong>
				</li>
				<li class="suite_frame_right">', $value['feedback'], '</li>';

				if($value['id_bug'] != 0)
					echo '
				<li class="text_style">
						<strong>', $txt['id_bug'], '</strong>', ' - ', $value['id_bug'], '
				</li>';
				if(!empty($value['modified_by']))
				{
					echo '
				<li class="modified">', $txt['ts_last_edit_by'], ' ', $value['modified_by'], ' ', $txt['at'], ' ', $value['modified_time'], '</li>';
				}

				echo '
				<li class="bottom_margin"><hr class="clear" /></li>';
			}
		echo '
		</ul>
		</div>';
		}
}

function template_sm_testsuite_count_link()
{
	global $txt, $scripturl, $context;
		
	// Start our template...
	echo '
	<div class="cat_bar">   
		<h3 class="catbg">', $context['test_suite']['suite']['link'], '</h3>
	</div>
	<div class="information">', $context['test_suite']['suite']['description'], '</div>';
	// Show info of the test cases created so far
	echo'
	<div class="suite_frame">
		<ul>';
						
	if ($context['test_suite']['result'] == 'fail' || $context['test_suite']['result'] == 'pass')
	{
		foreach ($context['test_suite']['run_links'] as $key => $value)
		{
			echo '
		<li class="text_style"><strong>', $txt['case_id'], '</strong>', ' - ', '<a href="', $value['href'], '">', $value['id_case'], '</a></li>';
			echo '
		<li class="text_style"><strong>', $txt['case_name'], '</strong>', ' - ', '<a href="', $value['href'], '">', $value['case_name'], '</a></li>';
			echo '
		<li class="text_style"><strong>', $txt['run_id'], '</strong>', ' - ', $value['link'], '</li>';
			echo '
		<li><hr class="clear" /></li>';
		}
	}
						
	else
	{
		foreach ($context['test_suite']['total_run_links'] as $key => $value)
		{
			echo '
		<li class="text_style"><strong>', $txt['case_id'], '</strong>', ' - ', '<a href="', $value['href'], '">', $value['id_case'], '</a></li>';
			echo '
		<li class="text_style"><strong>', $txt['case_name'], '</strong>', ' - ', '<a href="', $value['href'], '">', $value['case_name'], '</a></li>';
			echo '
		<li class="text_style"><strong>', $txt['run_id'], '</strong>', ' - ', $value['link'], '</li>';
			echo '
		<li><hr class="clear" /></li>';
		}
	}

		echo '
		</ul>
	</div>';
}

// Let make some creative(ohh creation functions :P).
function template_create_project()
{
		global $context, $txt, $scripturl;

		echo '
				<form action="', $context['test_suite']['url'], ';createproject2" method="post">';

		// Start the main table.
		echo '
				<div class="cat_bar">
						<h3 class="catbg">', $context['page_title'], '</h3>
				</div>
				<div>
						<span class="upperframe"><span></span></span>
						<div class="roundframe">';
								
		// If an error occurred, explain what happened.
		echo '
				<div class="errorbox"', empty($context['post_error']['description']) ? ' style="display: none"' : '', ' id="errors">
						<dl>
								<dt>
										<strong style="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'display: none;' : '', '" id="error_serious">', (empty($context['test_suite']['current_project']) ? $txt['error_while_creating_project'] : $txt['error_while_creating_suite']), '</strong>
								</dt>
								<dt class="error" id="error_list">
										', empty($context['post_error']['description']) ? '' : implode('<br />', $context['post_error']['description']), '
								</dt>
						</dl>
				</div>';

		// The post header... important stuff
		echo '
				<dl id="post_header">';

		// Show a box so that user can write the Project/Suite name
		echo '
				<dt>
						<label for="name">
								<span', isset($context['post_error']['name']) ? ' class="error"' : '', ' id="caption_subject">', $txt['name'], ':</span>
						</label>
				</dt>
				<dd>
						<input type="text" name="name" id="name"', isset($context['name']) ? ' value="' . $context['name'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" class="input_text" />
				</dd>';
												
		echo'
				</dl><hr class="clear" />';

		// Write description related to Project/Suite
		echo '
				<div class="textbox">
								<div class="text">
										<p>
												<label for="description">', $txt['description'], ':</label>
										</p>
								</div>
										<textarea class="editor" name="description" id="description" rows="20" cols="600" tabindex="', $context['tabindex']++, '" style="width: 70%; height: 150px; ', isset($context['post_error']['no_description']) || isset($context['post_error']['long_description']) ? 'border: 1px solid red;' : '', '">', isset($context['description']) ? $context['description'] : '', '</textarea>
				</div>';
		
		// Ohh take the Project ID if we're using this function for creation of suites
		echo'
				<input type="hidden" name="proj" value="', $context['test_suite']['current_project'] , '" />';

		// Finally, the submit button.
		echo '
				<br />
				<p class="righttext">
						<input type="submit" value="', $txt['create'], '" tabindex="', $context['tabindex']++, '" class="button_submit" />
				</p>
						</div>
						<span class="lowerframe"><span></span></span>
				</div>
				<br class="clear" />
		</form>';
}

// Just to make things less complicated one more function for level 3 & 4
function template_create_case()
{
		global $context, $txt, $scripturl;

		echo '
				<form action="', $context['test_suite']['url'], ';createcase2" method="post">';

		// Start the main table.
		echo '
				<div class="cat_bar">
						<h3 class="catbg">', $context['page_title'], '</h3>
				</div>
				<div>
						<span class="upperframe"><span></span></span>
						<div class="roundframe">';

		// If an error occurred, explain what happened.
		echo '
				<div class="errorbox"', empty($context['post_error']['message']) ? ' style="display: none"' : '', ' id="errors">
						<dl>
								<dt>
										<strong style="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'display: none;' : '', '" id="error_serious">', $txt['error_while_creating_case'], '</strong>
								</dt>
								<dt class="error" id="error_list">
										', empty($context['post_error']['message']) ? '' : implode('<br />', $context['post_error']['message']), '
								</dt>
						</dl>
				</div>';

		// The post header... important stuff
		echo '
				<dl id="post_header">';

		// Show a box so that user can write the Test Cases name
		echo '
		<dt>
				<label for="name">
						<span', isset($context['post_error']['name']) ? ' class="error"' : '', ' id="caption_name">', $txt['name'], ':</span>
				</label>
		</dt>
		<dd>
				<input type="text" name="name" id="name"', isset($context['name']) ? ' value="' . $context['name'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" class="input_text" />
		</dd>';

		echo'
				</dl><hr class="clear" />';

		// Write DESCRIPTION related to Test Cases
		echo'
				<div>
					<div class="description_text">', $txt['description'] ,':</div>
					<div class="description_box">';
		
		// Show the actual posting area (woohh BBC codes usage, never going to forget this part :()
		if ($context['show_bbc'])
		{
			echo '
					<div id="bbcBox_message"></div>';
		}

		// What about smileys?
		if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup']))
				echo '
						<div id="smileyBox_message"></div>';
		
		// Atlast show the box to type description
		echo '
				', template_control_richedit('message', 'smileyBox_message', 'bbcBox_message'); 
								
		echo '
					</div>
				</div><hr class="clear" />';

		
		// We need a box to type STEPS also
		echo'
				<div>
					<div class="description_text">', $txt['steps'] ,':</div>
					<div class="description_box">';
		
		// Show the actual posting area (woohh BBC codes usage, never going to forget this part :()
		if ($context['show_bbc'])
		{
			echo '
					<div id="bbcBox_steps"></div>';
		}

		// What about smileys?
		if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup']))
				echo '
					<div id="smileyBox_steps"></div>';
		
		// Atlast show the box to type description
		echo '
				', template_control_richedit('steps', 'smileyBox_steps', 'bbcBox_steps'); 
								
		echo '
					</div>
				</div><hr class="clear" />';

				
		// We need a box to type Expected Result also
		echo'
				<div>
					<div class="description_text">', $txt['expected_result'] ,':</div>
					<div class="description_box">';
		
		// Show the actual posting area (woohh BBC codes usage, never going to forget this part :()
		if ($context['show_bbc'])
		{
			echo '
					<div id="bbcBox_expected_result"></div>';
		}

		// What about smileys?
		if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup']))
				echo '
						<div id="smileyBox_expected_result"></div>';
		
		// Atlast show the box to type description
		echo '
				', template_control_richedit('expected_result', 'smileyBox_expected_result', 'bbcBox_expected_result'); 
								
		echo '
					</div>
				</div><hr class="clear" />';


				
		// So who's the champ to which this Case is going to be allotted
		echo '
				<dl id="post_header">
						<dt>
								<label for="id_assigned">
										<span', isset($context['post_error']['id_assigned']) ? ' class="error"' : '', ' id="caption_subject">', $txt['id_assigned'], ':</span>
								</label>
						</dt>
						<dd>
								<input type="text" name="id_assigned" id="id_assigned"', isset($context['id_assigned']) ? ' value="' . $context['id_assigned'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="10" maxlength="10" class="input_text" />
						</dd>
				</dl><hr class="clear" />';
		
		//Request the id's of Project, Suite and Test Case on our way to exit
				echo'
						<input type="hidden" name="s" value="', $context['test_suite']['current_suite'], '" />';

		// Finally, the submit buttons.
		echo '
				<br />
				<p class="righttext">
						<input type="submit" value="', $txt['create'], '" tabindex="', $context['tabindex']++, '" class="button_submit" />
				</p>
						</div>
						<span class="lowerframe"><span></span></span>
				</div>
				<br class="clear" />
		</form>';
}

function template_create_run()
{
		global $context, $txt, $scripturl;

		echo '
				<form action="', $context['test_suite']['url'], ';createrun2" method="post" enctype="multipart/form-data">';

		// Start the main table.
		echo '
				<div class="cat_bar">
						<h3 class="catbg">', $context['page_title'], '</h3>
				</div>
				<div>
						<span class="upperframe"><span></span></span>
						<div class="roundframe">';

		// If an error occurred, explain what happened.
		echo '
				<div class="errorbox"', empty($context['post_error']['feedback']) ? ' style="display: none"' : '', ' id="errors">
						<dl>
								<dt>
										<strong style="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'display: none;' : '', '" id="error_serious">', (empty($context['test_suite']['current_run']) ? $txt['error_while_creating_project'] : $txt['error_while_creating_run']), '</strong>
								</dt>
								<dt class="error" id="error_list">
										', empty($context['post_error']['feedback']) ? '' : implode('<br />', $context['post_error']['feedback']), '
								</dt>
						</dl>
				</div>';
				
	// The post header... important stuff
		echo '
				<dl id="post_header">';

		// So what's the result of the run?
		echo '
				<dt>
						<label for="result">
								<span', isset($context['post_error']['result']) ? ' class="error"' : '', ' id="caption_subject">', $txt['result'], ':</span>
						</label>
				</dt>
				<dd>
					<select name="result" tabindex="', $context['tabindex']++, '">
						<option value="select" selected="selected">', '(', $txt['select'], ')', '</option>
						<option value="pass"', (isset($context['result_achieved']) && ($context['result_achieved'] == 'pass')) ? ' selected="selected"' : '', '>', $txt['pass'], '</option>
						<option value="fail"', (isset($context['result_achieved']) && ($context['result_achieved'] == 'fail')) ? ' selected="selected"' : '', '>', $txt['fail'], '</option>
					</select>
				</dd>';
				
		echo'
				</dl><hr class="clear" />';

		// Ask user aout the feedback of the run he/she has made
		echo '
				<div>
						<div class="textbox">
								<div class="text">
										<p>
												<label for="feedback">', $txt['feedback'], ':</label>
										</p>
								</div>
										<textarea class="editor" name="feedback" id="feedback" rows="20" cols="600" tabindex="', $context['tabindex']++, '" style="width: 70%; height: 150px; ', isset($context['post_error']['no_feedback']) || isset($context['post_error']['long_feedback']) ? 'border: 1px solid red;' : '', '">', isset($context['feedback']) ? $context['feedback'] : '', '</textarea>
						</div>
				</div>';
				
		// Ask the bug ID, pitty we are asking users to submit this manually at this stage :(
		echo '
				<hr class="clear" />
				<dl id="post_header">
						<dt>
								<label for="id_bug">
										<span', isset($context['post_error']['id_bug']) ? ' class="error"' : '', ' id="caption_subject">', $txt['id_bug'], ':</span>
								</label>
						</dt>
						<dd>
								<input type="text" name="id_bug" id="id_bug"', isset($context['id_bug']) ? ' value="' . $context['id_bug'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="10" maxlength="10" class="input_text" />
						</dd>
				</dl>';

				//Request the id's of Project, Suite and Test Case on our way to exit
				echo'
						<input type="hidden" name="c" value="', $context['test_suite']['current_case'], '" />';

		// Finally, the submit buttons.
		echo '
				<br />
				<p class="righttext">
						<input type="submit" value="', $txt['submit'], '" tabindex="', $context['tabindex']++, '" class="button_submit" />
				</p>
						</div>
						<span class="lowerframe"><span></span></span>
				</div>
				<br class="clear" />
		</form>';
}

function template_edit_project()
{
		global $context, $txt, $scripturl;

		echo '
				<form action="', $context['test_suite']['url'], ';editproject2" method="post" enctype="multipart/form-data">';

		// Start the main table.
		echo '
				<div class="cat_bar">
						<h3 class="catbg">', $context['page_title'], '</h3>
				</div>
				<div>
						<span class="upperframe"><span></span></span>
						<div class="roundframe">';
								
		// If an error occurred, explain what happened.
		echo '
				<div class="errorbox"', empty($context['post_error']['description']) ? ' style="display: none"' : '', ' id="errors">
						<dl>
								<dt>
										<strong style="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'display: none;' : '', '" id="error_serious">', (empty($context['test_suite']['current_project']) ? $txt['error_while_creating_project'] : $txt['error_while_creating_suite']), '</strong>
								</dt>
								<dt class="error" id="error_list">
										', empty($context['post_error']['description']) ? '' : implode('<br />', $context['post_error']['description']), '
								</dt>
						</dl>
				</div>';

		// The post header... important stuff
		echo '
				<dl id="post_header">';

		// Show a box so that user can write the Project/Suite name
		echo '
						<dt>
								<label for="name">
										<span', isset($context['post_error']['name']) ? ' class="error"' : '', ' id="caption_subject">', $txt['name'], ':</span>
								</label>
						</dt>
						<dd>
								<input type="text" name="name" id="name"', isset($context['name']) ? ' value="' . $context['name'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" class="input_text" />
						</dd>';
												
		echo'
				</dl>
				<hr class="clear" />';

		// Write description related to Project/Suite
		echo '
				<div>
						<div class="textbox">
								<div class="text">
										<p>
												<label for="description">', $txt['description'], ':</label>
										</p>
								</div>
										<textarea class="editor" name="description" id="description" rows="20" cols="600" tabindex="', $context['tabindex']++, '" style="width: 70%; height: 150px; ', isset($context['post_error']['no_description']) || isset($context['post_error']['long_description']) ? 'border: 1px solid red;' : '', '">', isset($context['description']) ? $context['description'] : '', '</textarea>
						</div>
				</div>';
		
		// Ohh take the Project ID if we're using this function for creation of suites
		echo'
				<input type="hidden" name="proj" value="', $context['test_suite']['current_project'], '" />
				<input type="hidden" name="s" value="', $context['test_suite']['current_suite'], '" />';
				
		// Finally, the submit button.
		echo '
				<br />
				<p class="righttext">
						<input type="submit" value="', $txt['submit'], '" tabindex="', $context['tabindex']++, '" class="button_submit" />
				</p>
						</div>
						<span class="lowerframe"><span></span></span>
				</div>
				<br class="clear" />
		</form>';
}

// Just to make things less complicated one more function for level 3 & 4
function template_edit_case()
{
		global $context, $txt, $scripturl;

		echo '
				<form action="', $context['test_suite']['url'], ';editcase2" method="post">';

		// Start the main table.
		echo '
				<div class="cat_bar">
						<h3 class="catbg">', $context['page_title'], '</h3>
				</div>
				<div>
						<span class="upperframe"><span></span></span>
						<div class="roundframe">';

		// If an error occurred, explain what happened.
		echo '
				<div class="errorbox"', empty($context['post_error']['message']) ? ' style="display: none"' : '', ' id="errors">
						<dl>
								<dt>
										<strong style="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'display: none;' : '', '" id="error_serious">', $txt['error_while_creating_case'], '</strong>
								</dt>
								<dt class="error" id="error_list">
										', empty($context['post_error']['message']) ? '' : implode('<br />', $context['post_error']['message']), '
								</dt>
						</dl>
				</div>';

		// The post header... important stuff
		echo '
				<dl id="post_header">';

		// Show a box so that user can write the Test Cases name
		echo '
		<dt>
				<label for="name">
						<span', isset($context['post_error']['name']) ? ' class="error"' : '', ' id="caption_name">', $txt['name'], ':</span>
				</label>
		</dt>
		<dd>
				<input type="text" name="name" id="name"', isset($context['name']) ? ' value="' . $context['name'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" class="input_text" />
		</dd>';

		echo'
				</dl><hr class="clear" />';

		// Write DESCRIPTION related to Test Cases
		echo'
				<div>
					<div class="description_text">', $txt['description'] ,':</div>
					<div class="description_box">';
		
		// Show the actual posting area (woohh BBC codes usage, never going to forget this part :()
		if ($context['show_bbc'])
		{
			echo '
					<div id="bbcBox_message"></div>';
		}

		// What about smileys?
		if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup']))
				echo '
						<div id="smileyBox_message"></div>';
		
		// Atlast show the box to type description
		echo '
				', template_control_richedit('message', 'smileyBox_message', 'bbcBox_message'); 
								
		echo '
					</div>
				</div><hr class="clear" />';

		
		// We need a box to type STEPS also
		echo'
				<div>
					<div class="description_text">', $txt['steps'] ,':</div>
					<div class="description_box">';
		
		// Show the actual posting area (woohh BBC codes usage, never going to forget this part :()
		if ($context['show_bbc'])
		{
			echo '
					<div id="bbcBox_steps"></div>';
		}

		// What about smileys?
		if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup']))
				echo '
					<div id="smileyBox_steps"></div>';
		
		// Atlast show the box to type description
		echo '
				', template_control_richedit('steps', 'smileyBox_steps', 'bbcBox_steps'); 
								
		echo '
					</div>
				</div><hr class="clear" />';

				
		// We need a box to type Expected Result also
		echo'
				<div>
					<div class="description_text">', $txt['expected_result'] ,':</div>
					<div class="description_box">';
		
		// Show the actual posting area (woohh BBC codes usage, never going to forget this part :()
		if ($context['show_bbc'])
		{
			echo '
					<div id="bbcBox_expected_result"></div>';
		}

		// What about smileys?
		if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup']))
				echo '
						<div id="smileyBox_expected_result"></div>';
		
		// Atlast show the box to type description
		echo '
				', template_control_richedit('expected_result', 'smileyBox_expected_result', 'bbcBox_expected_result'); 
								
		echo '
					</div>
				</div><hr class="clear" />';
				
		// So who's the champ to which this Case is going to be allotted
		echo '
				<dl id="post_header">
						<dt>
								<label for="id_assigned">
										<span', isset($context['post_error']['id_assigned']) ? ' class="error"' : '', ' id="caption_subject">', $txt['id_assigned'], ':</span>
								</label>
						</dt>
						<dd>
								<input type="text" name="id_assigned" id="id_assigned"', isset($context['id_assigned']) ? ' value="' . $context['id_assigned'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="10" maxlength="10" class="input_text" />
						</dd>
				</dl><hr class="clear" />';
		
				//Request the id's of Project, Suite and Test Case on our way to exit
				echo'
						<input type="hidden" name="c" value="', $context['test_suite']['current_case'], '" />';

		// Finally, the submit buttons.
		echo '
				<br />
				<p class="righttext">
						<input type="submit" value="', $txt['submit'], '" tabindex="', $context['tabindex']++, '" class="button_submit" />
				</p>
						</div>
						<span class="lowerframe"><span></span></span>
				</div>
				<br class="clear" />
		</form>';
}

function template_edit_run()
{
		global $context, $txt, $scripturl;

		echo '
				<form action="', $context['test_suite']['url'], ';editrun2" method="post" enctype="multipart/form-data">';

		// Start the main table.
		echo '
				<div class="cat_bar">
						<h3 class="catbg">', $context['page_title'], '</h3>
				</div>
				<div>
						<span class="upperframe"><span></span></span>
						<div class="roundframe">';

		// If an error occurred, explain what happened.
		echo '
				<div class="errorbox"', empty($context['post_error']['feedback']) ? ' style="display: none"' : '', ' id="errors">
						<dl>
								<dt>
										<strong style="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'display: none;' : '', '" id="error_serious">', (empty($context['test_suite']['current_run']) ? $txt['error_while_creating_project'] : $txt['error_while_creating_run']), '</strong>
								</dt>
								<dt class="error" id="error_list">
										', empty($context['post_error']['feedback']) ? '' : implode('<br />', $context['post_error']['feedback']), '
								</dt>
						</dl>
				</div>';

		// The post header... important stuff
		echo '
				<dl id="post_header">';

		// So what's the result of the run?
		echo '
				<dt>
						<label for="result">
								<span', isset($context['post_error']['result']) ? ' class="error"' : '', ' id="caption_subject">', $txt['result'], ':</span>
						</label>
				</dt>
				<dd>
					<select name="result" tabindex="', $context['tabindex']++, '">
						<option value="select" selected="selected">', '(', $txt['select'], ')', '</option>
						<option value="pass"', 'pass' == $context['result_achieved'] ? ' selected="selected"' : '', '>', $txt['pass'], '</option>
						<option value="fail"', 'fail' == $context['result_achieved'] ? ' selected="selected"' : '', '>', $txt['fail'], '</option>
					</select>
				</dd>';
				
		echo'
				</dl><hr class="clear" />';

		// Ask user aout the feedback of the run he/she has made
		echo '
				<div>
						<div class="textbox">
								<div class="text">
										<p>
												<label for="feedback">', $txt['feedback'], ':</label>
										</p>
								</div>
										<textarea class="editor" name="feedback" id="feedback" rows="20" cols="600" tabindex="', $context['tabindex']++, '" style="width: 70%; height: 150px; ', isset($context['post_error']['no_feedback']) || isset($context['post_error']['long_feedback']) ? 'border: 1px solid red;' : '', '">', isset($context['feedback']) ? $context['feedback'] : '', '</textarea>
						</div>
				</div>';
				
		// Ask the bug ID, pitty we are asking users to submit this manually at this stage :(
		echo '
				<hr class="clear" />
				<dl id="post_header">
						<dt>
								<label for="id_bug">
										<span', isset($context['post_error']['id_bug']) ? ' class="error"' : '', ' id="caption_subject">', $txt['id_bug'], ':</span>
								</label>
						</dt>
						<dd>
								<input type="text" name="id_bug" id="id_bug"', isset($context['id_bug']) ? ' value="' . $context['id_bug'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="10" maxlength="10" class="input_text" />
						</dd>
				</dl>';
				
				//Request the id's of Project, Suite and Test Case on our way to exit
				echo'

						<input type="hidden" name="r" value="', $context['test_suite']['current_run'], '" />';
						
		// Finally, the submit buttons.
		echo '
				<br />
				<p class="righttext">
						<input type="submit" value="', $txt['submit'], '" tabindex="', $context['tabindex']++, '" class="button_submit" />
				</p>
						</div>
						<span class="lowerframe"><span></span></span>
				</div>
				<br class="clear" />
		</form>';
}

?>